<template>
  <div class="write-notes-wrap">
    <el-page-header class="page-header" :icon="null" @back="back">
      <template #extra>
        <div class="flex items-center">
          <el-button  class="ml-2" @click="preview">预览</el-button>
          <el-button  class="ml-2" @click="save">保存</el-button>
        </div>
      </template>
    </el-page-header>
    <div class="my-wangeditor-wrap">
      <my-wangeditor ref="mywangeditor"></my-wangeditor>
    </div>


    <!-- 预览短文 -->
    <PreviewContext ref="PreviewContextRef"  :previewTitle="essayPreviewTitle"  :previewContext="essayPreviewContext"></PreviewContext>
  </div>
</template>

<script>
import MyWangeditor from "./my-wangeditor.vue";
import PreviewContext from "@/components/PreviewContext/PreviewContext"


export default {
  name: "JddChromePluginsWriteNotes",
  components: { MyWangeditor,PreviewContext },
  data() {
    return {
      essayPreviewTitle:"",
      essayPreviewContext:"",
    };
  },

  mounted() {},

  methods: {
    back() {
      this.$router.back();
    },
    save() {
      this.$refs.mywangeditor.submitForm();
    },
    preview(){
      this.essayPreviewTitle = this.$refs.mywangeditor.ruleForm.title;
      this.essayPreviewContext = this.$refs.mywangeditor.valueHtml;
      this.$refs.PreviewContextRef.openDrawer();
    }
  },
};
</script>

<style lang="scss" scoped>
.page-header{
  padding: 15px 20px;
}
.title {
  font-size: 22px;
  font-weight: bolder;
}

</style>
